package com.hhsjdesign.dynamicui.utils

import android.graphics.Color
import com.hhsjdesign.dynamicui.core.property.ViewBaseProperty
import java.lang.Exception

object ColorUtil {

    private val colorMap: MutableMap<String, Int> = HashMap()

    fun parseColor(colorStr: String): Int {
        try {
            if (colorStr == ViewBaseProperty.TRANSPARENT) {
                return Color.TRANSPARENT
            }
            if (colorMap.containsKey(colorStr)) {
                return colorMap[colorStr] ?: Color.TRANSPARENT
            }
            return Color.parseColor(colorStr)
        } catch (e: Exception) {
            return Color.TRANSPARENT
        }
    }
}